home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Games / Game Sample Code / ZAM 1.0a13 / UtilCode / CoreAssertion.c next >
Encoding:
C/C++ Source or Header  |  1993-09-16  |  1.4 KB  |  40 lines  |  [TEXT/KAHL]

  1. #include "CoreAssertion.h"
  2.  
  3.  
  4.  
  5. strcatnum(char *str, short num)
  6. {
  7.     Str31    lineStr;
  8.     
  9.     NumToString((long)num,lineStr);    // convert number to pascal string
  10.     lineStr[lineStr[0]+1] = 0x00;    // null terminate the string
  11.     lineStr[0] = ' ';                // make first byte a space
  12.     strcat(str,lineStr);            // append number text to string
  13. }
  14.  
  15. void CoreAssert(short expEval, char *expr, char *file, short linenum)
  16. /* This routine will build an error message from the information passed */
  17. /* and drop into the debugger */
  18. {
  19.     char    str[256];
  20.     char    *header = "ASSERTION FAILURE: '";
  21.     char    *filePfx = "' IN FILE ";
  22.     char    *linePfx = " LINE #";
  23.     char    *postFix = "; SC6";
  24.     char    *evalPfx = " EXP =";
  25.     
  26.     strcpy(&str[1],header);            // put the asssertion failure message first
  27.     strcat(&str[1], (void*)expr);            // copy the expression that evaluated to false
  28.     strcat(&str[1], (void*)filePfx);        // display file prefix
  29.     strcat(&str[1], (void*)file);            // append file name to error message
  30.     strcat(&str[1],(void*)linePfx);        // display line number prefix
  31.     strcatnum(&str[1],linenum);        // display the line number
  32.     strcat(&str[1],(void*)evalPfx);        // display the evaluation prefix
  33.     strcatnum(&str[1],expEval);        // display the evaluation result
  34.  
  35.     /* Display the error message in the debugger */
  36.     strcat(&str[1],(void*)postFix);        // add macsbug commands to end of error message
  37.     str[0] = strlen(&str[1]);        // set the length byte for pascal string
  38.     DebugStr(str);
  39. }
  40.